/*
package com.yx.changdao.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yx.changdao.common.entity.CommunityBuild;
import com.yx.changdao.common.entity.CommunityBuildDetail;
import com.yx.changdao.common.entity.CommunityRegion;
import com.yx.changdao.common.entity.CommunityResident;
import com.yx.changdao.common.mapper.CommunityRegionMapper;
import com.yx.changdao.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.ArrayList;
import java.util.List;

*/
/**
 * @Description: <br/>
 * 区域信息表
 * <p>
 * <br/>
 * @Auther: flexible
 * @create 2020/04/02 16:42
 *//*

@Service
public class CommunityRegionServiceImpl extends ServiceImpl<CommunityRegionMapper, CommunityRegion> implements CommunityRegionService {
    */
/**
     * 网格信息库表服务
     *//*

    @Autowired
    private GridInfoService gridInfoService;
    */
/**
     * 区域信息表服务
     *//*

    @Autowired
    private CommunityRegionService communityRegionService;
    */
/**
     * 社区建筑物表服务
     *//*

    @Autowired
    private CommunityBuildService communityBuildService;
    */
/**
     * 户的服务
     *//*

    @Autowired
    private CommunityBuildDetailService communityBuildDetailService;
    @Autowired
    private CommunityResidentService communityResidentService;


    */
/**
     * 根据网格id获取有哪些区
     *//*

    @Override
    public List<CommunityRegion> getByGridinfoId(Integer gridInfoId) {

        return this.list(new QueryWrapper<CommunityRegion>().lambda()
                .eq(CommunityRegion::getGridId,gridInfoId)
        .orderByDesc(CommunityRegion::getCreateTime));
    }

    @Override
    public boolean removeBuild(Integer id) {
        //房id
        List<Integer> buildId = new ArrayList<>();
        List<CommunityBuild> communityBuild = communityBuildService
                .list(new QueryWrapper<CommunityBuild>().eq(CommunityBuild.REGION_ID, id));
        if(communityBuild.size()==0){
            return true;
        }
        for (CommunityBuild build : communityBuild) {
            buildId.add(build.getId());
        }
        //户id
        List<Integer> buildDetailId = new ArrayList<>();
        List<CommunityBuildDetail> buildDetails = communityBuildDetailService.list
                (new QueryWrapper<CommunityBuildDetail>().in(CommunityBuildDetail.BUILD_ID, buildId));
        if(buildDetails.size()==0){
            //户为空，删除房建筑
            //删除楼
            boolean buildRemove = communityBuildService.remove
                    (new QueryWrapper<CommunityBuild>().in(CommunityBuild.ID, buildId));
            if (!buildRemove) {
                return  false;
            }
            return true;

        }
        for (CommunityBuildDetail buildDetail : buildDetails) {
            buildDetailId.add(buildDetail.getId());
        }
        //居民id
        List<CommunityResident> residents = communityResidentService.list
                (new QueryWrapper<CommunityResident>().in(CommunityResident.BUILD_DETAIL_ID, buildDetailId));
        for (CommunityResident integer : residents) {
            integer.setBuildDetailId(0);
            //更新居民
            communityResidentService.updateById(integer);
        }
        //删除户
        boolean buildDetailRemove = communityBuildDetailService.remove
                (new QueryWrapper<CommunityBuildDetail>().in(CommunityBuildDetail.ID, buildDetailId));
        if (!buildDetailRemove) {
            return false;
        }
        //删除楼
        boolean buildRemove = communityBuildService.remove
                (new QueryWrapper<CommunityBuild>().in(CommunityBuild.ID, buildId));
        if (!buildRemove) {
            return  false;
        }
        return true;
    }
}
*/
